package exercise.jslide.jslide.utils;

import java.io.*;

public class SerializationUtils {

    // 序列化对象到文件
    public static void serialize(Object obj, File file) throws IOException {
        try (ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(file))) {
            out.writeObject(obj);
        }
    }

    // 从文件反序列化对象
    public static Object deserialize(File file) throws IOException, ClassNotFoundException {
        try (ObjectInputStream in = new ObjectInputStream(new FileInputStream(file))) {
            return in.readObject();
        }
    }
}